package com.zkt.weichat.handler;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author 赵开泰
 * @program jc-club
 * @date 2025/3/23 01:33
 * @description 关注实现handler
 **/

@Component
@Slf4j
public class SubscribeMagHandler implements WeichatMsgHandler {
	
	@Override
	public WeichatMsgTypeEnum getMsgType() {
		return WeichatMsgTypeEnum.SUBSCRIBE;
	}
	
	@Override
	public String dealMsg(Map<String, String> msgMap) {
		log.info("触发用户关注事件！");
		
		String toUserName = msgMap.get("ToUserName");
		String fromUserName = msgMap.get("FromUserName");
		String subscribeContent = "感谢您的关注，我是测试！欢迎使用智能练题平台！";
		
		return "<xml>\n" +
				"  <ToUserName><![CDATA[" + fromUserName + "]]></ToUserName>\n" +
				"  <FromUserName><![CDATA[" + toUserName + "]]></FromUserName>\n" +
				"  <CreateTime>1348831860</CreateTime>\n" +
				"  <MsgType><![CDATA[text]]></MsgType>\n" +
				"  <Content><![CDATA[" + subscribeContent + "]]></Content>\n" +
				"</xml>";
	}
}